import axios from '@/libs/api.request'
import { getIsTeam } from '@/libs/util'

export const getMeetDevice = ({ pageNum, pageSize }) => {
  return axios.request({
    url: 'get_meet_device',
    params: {
      pageNum,
      pageSize
    },
    method: 'get'
  })
}

export const setMeetDeviceState = ({ id, setAction }) => {
  return axios.request({
    url: 'set_meet_device_state',
    params: {
      id,
      setAction
    },
    method: 'get'
  })
}

export const delMeetDevice = (id) => {
  return axios.request({
    url: 'del_meet_device',
    params: {
      id
    },
    method: 'get'
  })
}

export const editMeetDevice = ({ id, team_id, name, state }) => {
  const data = {
    id,
    team_id,
    name,
    state
  }
  return axios.request({
    url: 'edit_meet_device',
    data,
    method: 'post'
  })
}

export const addDevice = ({ name, team_id, state }) => {
  if (getIsTeam()) {
    team_id = null
  }
  const data = {
    name,
    team_id,
    state
  }
  return axios.request({
    url: 'add_meet_device',
    data,
    method: 'post'
  })
}

export const getMeetRecord = ({ pageNum, pageSize }) => {
  return axios.request({
    url: 'get_meet_record',
    params: {
      pageNum,
      pageSize
    },
    method: 'get'
  })
}

export const getDeviceArr = (team_id) => {
  if (getIsTeam()) {
    team_id = null
  }
  return axios.request({
    url: 'get_device_arr',
    params: {
      team_id
    },
    method: 'get'
  })
}

export const addMeetRoom = ({ team_id, name, photo, capacity, equip, address, ischeck, state }) => {
  if (getIsTeam()) {
    team_id = null
  }
  const data = {
    team_id,
    name,
    photo,
    capacity,
    equip,
    address,
    ischeck,
    state
  }
  return axios.request({
    url: 'add_meet_room',
    data,
    method: 'post'
  })
}

export const getMeetRoom = ({ pageNum, pageSize }) => {
  return axios.request({
    url: 'get_meet_room',
    params: {
      pageNum,
      pageSize
    },
    method: 'get'
  })
}

export const setRoomState = ({ id, setAction, team_id }) => {
  if (getIsTeam()) {
    team_id = null
  }
  return axios.request({
    url: 'set_room_state',
    params: {
      id,
      setAction,
      team_id
    },
    method: 'get'
  })
}

export const delRoom = ({ id, team_id }) => {
  if (getIsTeam()) {
    team_id = null
  }
  return axios.request({
    url: 'del_room',
    params: {
      id,
      team_id
    },
    method: 'get'
  })
}

export const editRoom = ({ id, team_id, name, photo, capacity, equip, address, ischeck, state }) => {
  const data = {
    id,
    team_id,
    name,
    photo,
    capacity,
    equip,
    address,
    ischeck,
    state
  }
  return axios.request({
    url: 'edit_room',
    data,
    method: 'post'
  })
}

export const getMeetDetail = ({ meet_id, master_id, pageNum, pageSize }) => {
  return axios.request({
    url: 'get_meet_detail',
    params: {
      meet_id,
      master_id,
      pageNum,
      pageSize
    },
    method: 'get'
  })
}

export const getRoomInfo = (room_id) => {
  return axios.request({
    url: 'get_room_info',
    params: {
      room_id
    },
    method: 'get'
  })
}
